<?php
require('clases/user.class.php');
$objUser=new User;
$consulta=$objUser->mostrar_users();
?>
<script type="text/javascript">
$(document).ready(function(){
	// mostrar formulario de actualizar datos
	$("table tr .modi a").click(function(){
		$('#tabla').hide();
		$("#formulario").show();
		$.ajax({
			url: this.href,
			type: "GET",
			success: function(datos){
				$("#formulario").html(datos);
			}
		});
		return false;
	});
	
	// llamar a formulario nuevo
	$("#nuevo a").click(function(){
		$("#formulario").show();
		$("#tabla").hide();
		$.ajax({
			type: "GET",
			url: 'nuser.php',
			success: function(datos){
				$("#formulario").html(datos);
			}
		});
		return false;
	});
});

</script>
<div id="container">
			
			<div id="demo">

<span id="nuevo"><a href="nuser.php"><img src="img/add.png" alt="Agregar dato" /></a></span><br/><br/>
	<table id="example" class="display">

	
    <thead>
   		<tr>
   			<th>Nombre</th>
    		<th>Apellido</th>
    		<th>Login</th>
    		<th>Password</th>
            <th>Rol</th>
            <th>Editar</th>
            <th>Eliminar</th>
        </tr>
        </thead>
        <tbody>
<?php
if($consulta) {
	while( $user = mysql_fetch_array($consulta) ){
	?>
	
		  <tr id="fila-<?php echo $user['id'] ?>">
			  <td><?php echo $user['nombre'] ?></td>
			  <td><?php echo $user['apellido'] ?></td>
			  <td><?php echo $user['login'] ?></td>
			  <td><input type="password" value="<?php echo $user['psw'] ?>" style="width:100%; border:none; background-color:transparent; text-align:center" disabled="disabled";/></td>
			  <td><?php echo $user['role'] ?></td>             
			  <td class="center"><span class="modi"><a href="actuser.php?id=<?php echo $user['id'] ?>"><img src="img/database_edit.png" title="Editar" alt="Editar" /></a></span></td>
			  <td class="center"><span class="dele"><a onClick="EliminarUser(<?php echo $user['id'] ?>); return false" href="spruser.php?id=<?php echo $user['id'] ?>"><img src="img/delete.png" title="Eliminar" alt="Eliminar" /></a></span></td>
		  </tr>
	<?php
	}
}
?></tbody>
    </table>
    </div>
			<div class="spacer"></div>
			
			
			
			</div>
		</div>